package com.sasu.university_data;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

@SpringBootApplication
public class UniversityDataApplication {

    public static void main ( String[] args ) {
        SpringApplication.run(UniversityDataApplication.class, args);
    }


    /**
     * 提升框架接受文件的最大限度
     *
     * @return {@link MultipartConfigElement }
     * @author qionglan
     * @date 2024/06/14 16:44:14
     **/

    @Bean
    public MultipartConfigElement setMCE(){
        MultipartConfigFactory mcf=new MultipartConfigFactory();
        //提升至100MB
        mcf.setMaxRequestSize(DataSize.ofMegabytes(100));
        //提升接受文件大小至100MB
        mcf.setMaxFileSize(DataSize.ofMegabytes(100));

        //return  即是设定
        return mcf.createMultipartConfig();
    }
}
